<extend name="Layout/ins_page" />
<block name="content">
    <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
    <script src="/sap/scripts/boot.js" type="text/javascript"></script>
    <style>
		table img{width: 40px}
	</style>
<body style="">    
  <br/>
  
      <h5>项目申请单: <?php echo $info['name'];?></h5>
      <h5>发起人: <?php echo $info['user'];?></h5>
  项目类型: <input  id='cgtype'   readonly="readonly"   name="" showNullItem="true" class="mini-combobox" value="<?php echo $info['type']?>" data="[{'id':1,'text':'内部'},{'id':2,'text':'外部'}]" valueField="id" textField="text"  onValuechanged='cgfschange' />
  项目负责人: <input  id='cplist'  readonly="readonly"  name="" showNullItem="true" class="mini-combobox" value="<?php echo $info['manager']?>" url="/stocking/getUser?type=1" valueField="id" textField="text"/><br/><br/>
  项目描述: <input readonly class="mini-textarea" style="width:400px;height: 400px" minWidth="400" minHeight="400" value="<?php echo $info['remarkes']?>" />
         <br/>
  <div id='editForm1'>
   <?php if(isset($access)&&$access){?>
    <br/>
             备注: <input id="remarkes" class="mini-textarea" style="width:400px;" minWidth="200" minHeight="100" value="" />
    <br/> <br/>

      <if condition="$urgentEnable">
          <div>
          <a class="mini-button" onclick="urgentEnable(1)"  id='query-bt' style="background-color: #81de81;color: white;width: 205px;height: 30px;line-height: 30px;font-weight: bold;" >&nbsp;&nbsp;加急&nbsp;&nbsp;</a>
          </div>
      </if>
   
    <a class="mini-button" onclick="review(1)" id='query-bt' style="background-color: #81de81;color: white;width: 100px;height: 30px;line-height: 30px;font-weight: bold;" >&nbsp;&nbsp;通过&nbsp;&nbsp;</a>
    <a class="mini-button" onclick="review(-1)"  id='query-bt' style="background-color: #de4c2b;color: white;width: 100px;height: 30px;line-height: 30px;font-weight: bold;" >&nbsp;&nbsp;不通过&nbsp;&nbsp;</a>
    <?php };?>
  </div>
  <h4>操作记录</h4>
  <ul>
  <?php foreach($log as $vo ){?>
  <li><?php echo $vo['user'].'在'. $vo['ctime'].' '.$vo['info'] ;?></li>
  <?php }?>
  </ul>
  
</body>
<script type="text/javascript">
        mini.parse();
        var whouselist = [{ id: 'HYWCK', text: '联谊路仓库' }, { id: 'A07', text: '样品仓库'},{ id: 'A02', text: '虚拟卡券'},{ id: 'H03', text: '3号仓库'}];
        var grid = mini.get("datagrid1");
        grid.load({id:<?php echo $info['id'];?>});
        
        grid.on("drawcell", function (e) {
        var record = e.record,
        column = e.column,
        field = e.field,
        value = e.value;
            //格式化日期
            if (field == "storage_time") {
                if (mini.isDate(value)) e.cellHtml = mini.formatDate(value, "yyyy-MM-dd HH:mm:ss");
				
            }
            
            if (field == "amout"||field == "total_price"||field=="storage_time"||field=="p_price") {
        		  e.cellStyle = "background:#ecedef";
              }

        });

 		function review(status){
 			
 		        mini.confirm("确定要执行该操作吗？", "确定?",
 		            function (action) {
 		                if (action == "ok") {
 		                	doreview(status);
 		                } else {
 		                   
 		                }
 		            }
 		        );
 		    
 			
 		}
        function doreview(status) {
    
             mini.mask({
                el: document.body,
                cls: 'mini-mask-loading',
                html: '保存中...'
            }); 
             
            var  remarkes = mini.get('remarkes').getValue();
             
            $.ajax({
                url: "/Project/review",
                data: { id: <?php echo $info['id']?>,status:status,remarkes:remarkes},
                type: "post",
                dataType:'json',
                success: function (data) {
                   if(data.code==0){
                	    mini.unmask(document.body);
						mini.alert('保存成功!');
						location.reload();   
						return ;
                   }else{
                	   mini.unmask(document.body);
                	   mini.alert(data.msg);
                       }
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                }
            });
        }


        function urgentEnable(status){

            mini.confirm("确定要执行该操作吗？", "确定?",
                function (action) {
                    if (action == "ok") {
                        doUrgentEnable(status);
                    } else {

                    }
                }
            );


        }
        function doUrgentEnable(status) {

            mini.mask({
                el: document.body,
                cls: 'mini-mask-loading',
                html: '保存中...'
            });

            var  remarkes = mini.get('remarkes').getValue();

            $.ajax({
                url: "/Stocking/doUrgentEnable",
                data: { id: <?php echo $info['id']?>,status:status,remarkes:remarkes},
            type: "post",
                dataType:'json',
                success: function (data) {
                if(data.code==0){
                    mini.unmask(document.body);
                    mini.alert('保存成功!');
                    location.reload();
                    return ;
                }else{
                    mini.unmask(document.body);
                    mini.alert(data.msg);
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert(jqXHR.responseText);
            }
        });
        }

    </script>
  
</body>
</block>
<block name="js">
	<script type="text/javascript">

	</script>
</block>